package com.xp.interview.controller;

import com.xp.interview.service.EditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * Created by xp on 15/10/15.
 */
@Controller
public class EditController {

    @Autowired
    private EditService editService;

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public String updateNote(@RequestParam(value = "noteId",required = true) String id,
                            @RequestParam(value = "title",required = true) String title,
                             @RequestParam(value = "content",required = true) String content)
    {
        editService.updateNote(id,title,content);
        return "index";
    }
    @RequestMapping(value = "/remove",method = RequestMethod.GET)
    @ResponseBody
    public String removeNote(@RequestParam(value = "noteId",required = true) String id)
    {
        editService.removeNote(id);
        return "index";
    }
}
